package org.xenon.vote.model.pojo.vo;

import org.xenon.vote.model.bo.CaptchaFac;
import org.xenon.vote.model.bo.CaptchaImg;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;

public class Captcha {
    private final BufferedImage bi;
    private final String text;
    private final String session;

    public Captcha(String session, CaptchaImg image) {
        this.bi = image.getBi();
        this.text = image.getText();
        this.session = session;
    }

    public BufferedImage getImg() {
        return bi;
    }

    public String getText() {
        return text;
    }

    public String getSession() {
        return session;
    }

    public static void output(BufferedImage image, OutputStream out) throws IOException {
        ImageIO.write(image, "JPEG", out);
    }
}
